package com.flyxiaozhu.erp.service.resps;

import com.flyxiaozhu.erp.core.entities.Goods;
import com.flyxiaozhu.erp.core.entities.GoodsPicture;
import com.flyxiaozhu.erp.core.entities.GoodsTag;
import com.flyxiaozhu.erp.core.utils.CollectionUtils;
import lombok.Data;

import java.util.List;

@Data
public class GoodsResp extends BaseResp {
    private long id;

    private String name;

    private String goodsNo;

    private long categoryId;

    private String thumb;

    private int sellingPrice;

    private int marketPrice;

    private String detail;

    private Boolean hasMultiSku;

    private int stock;

    private int status;

    private List<GoodsTag> tags;

    private List<GoodsPicture> goodsPictures;

    private List<GoodsAttrResp> attrs;

    private List<GoodsSkuResp> goodsSkus;

    public GoodsResp(Object o) {
        super(0);
    }

    public GoodsResp(Goods goods) {
        super(goods);

        if (goods.getAttrs() != null) {
            attrs = CollectionUtils.map(goods.getAttrs(), GoodsAttrResp::new);
        }

        if (goods.getGoodsSkus() != null) {
            goodsSkus = CollectionUtils.map(goods.getGoodsSkus(), GoodsSkuResp::new);
        }
    }
}
